package cn.facetoken.homer;

import androidx.annotation.NonNull;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;

public class Migration2 extends Migration {

    private Migration2() {
        super(1, 2);
    }

    private static Migration2 instance;

    @Override
    public void migrate(@NonNull SupportSQLiteDatabase database) {
        final String sql = new StringBuilder().
                append("CREATE TABLE `face_sample` (").
                append("  `id` INTEGER NOT NULL PRIMARY KEY,").
                append("  `name` TEXT,").
                append("  `sample_uri` TEXT NOT NULL,").
                append("  `face_feature` TEXT,").
                append("  `eyeprint_feature` TEXT,").
                append("  `created_at` INTEGER NOT NULL DEFAULT CURRENT_TIMESTAMP,").
                append("  `updated_at` INTEGER NOT NULL DEFAULT CURRENT_TIMESTAMP);").toString();
        database.execSQL(sql);
    }

    public static Migration2 getInstance() {
        if (null!=instance) {
            return instance;
        }

        synchronized (Migration2.class) {
            if (null==instance) {
                instance = new Migration2();
            }
            return instance;
        }
    }
}
